//
//  TYHomeFunctionCategoryCell.m
//  爱鲜蜂
//
//  Created by 李田 on 16/11/19.
//  Copyright © 2016年 tianyao. All rights reserved.
//

#import "LBHomeFunctionCategoryCell.h"
#import <UIImageView+WebCache.h>
#import "LBActivityModel.h"
@implementation LBHomeFunctionCategoryCell


- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    
    //    MARK: 效果的View
    UIView *effectV = [[UIView alloc] init];
    effectV.backgroundColor = [UIColor cz_randomColor];
    [self.contentView addSubview:effectV];
    //    MARK: titlleB
    UIButton *titleB = [UIButton cz_textButton:@"优选水果" fontSize:14 normalColor:[UIColor cz_colorWithHex:0xF38D3D] selectedColor:[UIColor cz_colorWithHex:0xF38D3D]];
    [self.contentView addSubview:titleB];
    _titleB = titleB;
    //    MARK: moreBtn
    UIButton *moreBtn = [UIButton cz_textButton:@"更多" fontSize:14 normalColor:[UIColor cz_colorWithHex:0x999999] selectedColor:[UIColor cz_colorWithHex:0x999999]];
    
    [moreBtn addTarget:self action:@selector(moreBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:moreBtn];
    //    MARK:RightImgV
    UIImageView *rightImageV = [[UIImageView alloc] init];
    rightImageV.image = [UIImage imageNamed:@"icon_go"];
    [self.contentView addSubview:rightImageV];
    //    MARK: bigIconImage
    UIImageView *bigIconImageV = [[UIImageView alloc] init];
//    bigIconImageV.image = [UIImage imageNamed:@"meinv_2"];
    [self.contentView addSubview:bigIconImageV];
    _bigIconImageV = bigIconImageV;
    //    MARK: 布局
    [effectV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(13);
        make.left.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(4, 15));
    }];
    
    [titleB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(effectV.mas_right).offset(6);
        make.top.mas_equalTo(6);
    }];
    
    [rightImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(14);
    }];
    
    [moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(rightImageV.mas_left).offset(-6);
        make.top.mas_equalTo(6);
    }];
    
    [bigIconImageV  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(40);
        make.left.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(355, 90));
    }];
}


- (void)setModel:(LBActRowsModel *)model
{
    _model = model;
    
    [self.bigIconImageV sd_setImageWithURL:[NSURL URLWithString:model.activity.img]];
    
    [self.titleB setTitle:model.activity.name forState:UIControlStateNormal];
    
}

- (void)moreBtnClick: (UIButton *)sender{
    
    if ([_delegate respondsToSelector:@selector(homeFunctionCategoryCell:)]) {
        [_delegate homeFunctionCategoryCell:self];
    }
}


@end
